package com.example.player.presentation.adaptor;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.player.presentation.fragment.LocalMusicFragment;
import com.example.player.presentation.fragment.PlaylistsFragment;

/**
 * 首页分区适配器
 * ...音乐、歌单...
 * @author 朱文权
 * */
public class MainViewPagerAdaptor extends FragmentStateAdapter {
    public MainViewPagerAdaptor(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch(position){
            case 0:
                return new LocalMusicFragment();
            case 1:
                return new PlaylistsFragment();
            default:
                throw new IllegalArgumentException("fragment创建异常");
        }
    }
    @Override
    public int getItemCount() {
        return 2;
    }
}
